<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>borrow_list</title>
    <link rel="stylesheet" href="/static/css/index.css">
    <link rel="stylesheet" href="/static/css/borrow_list.css">
    <script type="text/javascript" src="/static/js/jquery-1.7.2.js"></script>
    <script>
        $(function () {
            $(".returnBook").click(function () {
                //获取item名称
                var title = $(this).attr("id");
                return confirm("确定要归还【"+title+"】吗？");
            });
        });
    </script>
</head>
<body>
<div class="header">
    {{if .IsLogin}}
        <div>
            普通用户：{{.Username}}
        </div>
        <div>
            <a href="/logout">注销</a>
            <a href="/getBookByTitleOrAuthor">图书列表</a>
            <a href="/getBorrowRecord">我的借阅</a>
            <a href="/main">返回</a>
        </div>
    {{else}}
        你还未登录<a href="/main">返回</a>
    {{end}}
</div>
<div id="main">
  {{if .BorrowItem}}
    <div class="borrow_record">
        <table>
            <tr>
                <th>书号</th>
                <th>书名</th>
                <th>作者</th>
                <th>出版社</th>
                <th>定价</th>
                <th>图片</th>
                <th>数量</th>
                <th>借书时间</th>
                <th>操作</th>
            </tr>
            {{range .BorrowItem}}
                <tr>
                    <td>{{.BookId}}</td>
                    <td>{{.Book.Title}}</td>
                    <td>{{.Book.Author}}</td>
                    <td>{{.Book.Publish}}</td>
                    <td>{{.Book.Price}}</td>
                    <td><img src="{{.Book.ImgPath}}" alt=""></td>
                    <td>{{.BorrowNums}}</td>
                    <td>{{.BorrowTime}}</td>
                    <td><a id="{{.Book.Title}}" class="returnBook" href="/returnBook?borrowItemId={{.BorrowItemId}}">归还</a></td>
                </tr>
            {{end}}
        </table>
        <div>
            <span style="font-size: 24px;">一共借了{{.TotalNums}}本书</span>
            <span><a href="/getBookByTitleOrAuthor">继续借书</a></span>
        </div>
    </div>
    {{else}}
      <div>你还没有借书</div>
    {{end}}
</div>

</body>
</html>